part of '../repository.dart';

const _kWebPaymentFailureCardExpiredValue = 'card_expired';
const _kWebPaymentFailureCardUnavailableValue = 'card_unavailable';

class _WebPaymentMethodFailureDto extends Equatable {
  const _WebPaymentMethodFailureDto._internal({
    required this.failureString,
  });

  final String failureString;

  @override
  List<Object?> get props {
    return [
      failureString,
    ];
  }

  factory _WebPaymentMethodFailureDto.fromString(String failureString) {
    return _WebPaymentMethodFailureDto._internal(
      failureString: failureString,
    );
  }

  WebPaymentMethodFailure toEntity() {
    return switch (failureString) {
      _kWebPaymentFailureCardExpiredValue => WebPaymentMethodFailure.cardExpired,
      _kWebPaymentFailureCardUnavailableValue => WebPaymentMethodFailure.cardUnavailable,
      _ => throw UnimplementedError(),
    };
  }
}
